import {Navigate} from 'react-router-dom'
import propTypes from 'prop-types'
function Private(props) {
  // 如果有token就返回子节点，没有就跳转到 /
  if(sessionStorage.getItem("token")){
    return  props.children;
  }else{
    // Navigate用于重定向跳转
    return <Navigate to="/"></Navigate>
  }
  
}
Private.propTypes = {
  children:propTypes.element
}

export default Private;